//
//  SettleMessageViewController.m
//  跨界收
//
//  Created by Allen on 2018/11/20.
//  Copyright © 2018年 gztx. All rights reserved.
//

#import "SettleMessageViewController.h"
#import "SettleMessageTableViewCell.h"
#import "JiBenXinXiView.h"

@interface SettleMessageViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (weak, nonatomic) IBOutlet UITableView *tableview;
@property (nonatomic, strong) NSArray *sectionArray;
@property (nonatomic, strong) NSArray *titleArray;
@property (nonatomic, strong) NSArray *titleArray1;
@property (nonatomic, strong) NSArray *placeholder;
@property (nonatomic, strong) NSArray *placeholder1;
@property (nonatomic, strong) NSArray *placeholder2;
@end

@implementation SettleMessageViewController
- (void)initData
{
    _sectionArray = @[@"结算信息",@""];
    _titleArray = @[@"开户名",@"银行账号"];
    _titleArray1 = @[@"开户银行",@"银行支行",@"预览手机"];
    _placeholder = @[@"请输入开户名",@"请输入银行账号"];
    _placeholder1 = @[@"自动读取",@"请选择",@"请输入"];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"结算信息";
    [self initData];
    self.tableview.delegate = self;
    self.tableview.dataSource = self;
    self.tableview.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
    [self.tableview registerNib:[UINib nibWithNibName:@"SettleMessageTableViewCell" bundle:nil] forCellReuseIdentifier:@"cell"];
    UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 80)];
    header.backgroundColor = [UIColor whiteColor];
    JiBenXinXiView *view = [JiBenXinXiView shareInstance];
    for (id label in view.threeView.subviews) {
        if ([label isKindOfClass:[UILabel class]]) {
            UILabel *oneLabel = (UILabel *)label;
            oneLabel.textColor = [UIColor cz_colorWithHex:0x239fdb];
        }
    }
    view.frame = CGRectMake(0, 0, SCREEN_WIDTH, 80);
    [header addSubview:view];
    self.tableview.tableHeaderView = header;
    // Do any additional setup after loading the view from its nib.
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        UIView *headerview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 30)];
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, 300, 30)];
        label.text = _sectionArray[section];
        label.textColor = [UIColor lightGrayColor];
        label.font = [UIFont systemFontOfSize:16];
        [headerview addSubview:label];
        return headerview;
    }
    return nil;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 30;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return _sectionArray.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        return _titleArray.count;
    }else
        return _titleArray1.count;
   
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *indetifier = @"cell";
    SettleMessageTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indetifier];
    if (!cell) {
        cell = [[SettleMessageTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indetifier];;
    }
    switch (indexPath.section) {
        case 0:
        {
            cell.titleLabel.text = _titleArray[indexPath.row];
            cell.contentTextField.placeholder = _placeholder[indexPath.row];
//            switch (indexPath.row) {
//                case 0:
//                case 1:
//                case 2:
//                case 4:
//                {
//                    cell.contentTextField.hidden = NO;
//                    cell.startDateTextField.hidden = YES;
//                    cell.endTextField.hidden = YES;
//                    cell.label.hidden = YES;
//                }
//                    break;
//                case 3:{
//                    cell.contentTextField.hidden = YES;
//                    cell.startDateTextField.hidden = NO;
//                    cell.endTextField.hidden = NO;
//                    cell.label.hidden = NO;
//                }
//                    break;
//                default:
//                    break;
//            }
        }
            break;
        case 1:
        {
            cell.titleLabel.text = _titleArray1[indexPath.row];
            cell.contentTextField.placeholder = _placeholder1[indexPath.row];
            switch (indexPath.row) {
                case 0:
                {
                   cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
                }
                    break;
               
                default:
                    break;
            }
        }
            break;
        default:
            break;
    }
    return cell;
}
@end
